package com.lc202309;

/**
 * Description:
 *
 * @Create 2023/9/15 22:42
 * @Version 1.0
 */
public class Solution50 {
    public int giveGem(int[] gem, int[][] operations) {
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for (int[] operation : operations) {
            gem[operation[1]] = gem[operation[1]] + gem[operation[0]] / 2;
            gem[operation[0]] = gem[operation[0]] - gem[operation[0]] / 2;
        }
        for (int i : gem) {
            min = Math.min(i, min);
            max = Math.max(i, max);
        }
        return max - min;
    }
}
